// mutationobserver-shim v0.3.1 (github.com/megawac/MutationObserver.js)
// Authors: Graeme Yeates (github.com/megawac) 
window.MutationObserver = window.MutationObserver || window.WebKitMutationObserver || function(r) {
    function w(a) {
        this.g = [];
        this.k = a
    }

    function H(a) {
        (function c() {
            var d = a.takeRecords();
            d.length && a.k(d, a);
            a.f = setTimeout(c, w._period)
        })()
    }

    function t(a) {
        var b = {
                type: null,
                target: null,
                addedNodes: [],
                removedNodes: [],
                previousSibling: null,
                nextSibling: null,
                attributeName: null,
                attributeNamespace: null,
                oldValue: null
            },
            c;
        for (c in a) b[c] !== r && a[c] !== r && (b[c] = a[c]);
        return b
    }

    function I(a, b) {
        var c = B(a, b);
        return function(d) {
            var g =
                d.length,
                n;
            b.a && c.a && A(d, a, c.a, b.d);
            if (b.b || b.e) n = J(d, a, c, b);
            if (n || d.length !== g) c = B(a, b)
        }
    }

    function A(a, b, c, d) {
        for (var g = {}, n = b.attributes, h, m, C = n.length; C--;) h = n[C], m = h.name, d && d[m] === r || (h.value !== c[m] && a.push(t({
            type: "attributes",
            target: b,
            attributeName: m,
            oldValue: c[m],
            attributeNamespace: h.namespaceURI
        })), g[m] = !0);
        for (m in c) g[m] || a.push(t({
            target: b,
            type: "attributes",
            attributeName: m,
            oldValue: c[m]
        }))
    }

    function J(a, b, c, d) {
        function g(b, c, g, h, y) {
            var r = b.length - 1;
            y = -~((r - y) / 2);
            for (var f, k, e; e = b.pop();) f =
                g[e.h], k = h[e.i], d.b && y && Math.abs(e.h - e.i) >= r && (a.push(t({
                    type: "childList",
                    target: c,
                    addedNodes: [f],
                    removedNodes: [f],
                    nextSibling: f.nextSibling,
                    previousSibling: f.previousSibling
                })), y--), d.a && k.a && A(a, f, k.a, d.d), d.c && 3 === f.nodeType && f.nodeValue !== k.c && a.push(t({
                    type: "characterData",
                    target: f
                })), d.e && n(f, k)
        }

        function n(b, c) {
            for (var x = b.childNodes, p = c.b, y = x.length, w = p ? p.length : 0, f, k, e, l, u, z = 0, v = 0, q = 0; v < y || q < w;) l = x[v], u = (e = p[q]) && e.j, l === u ? (d.a && e.a && A(a, l, e.a, d.d), d.c && e.c !== r && l.nodeValue !== e.c && a.push(t({
                type: "characterData",
                target: l
            })), k && g(k, b, x, p, z), d.e && (l.childNodes.length || e.b && e.b.length) && n(l, e), v++, q++) : (h = !0, f || (f = {}, k = []), l && (f[e = D(l)] || (f[e] = !0, -1 === (e = E(p, l, q, "j")) ? d.b && (a.push(t({
                type: "childList",
                target: b,
                addedNodes: [l],
                nextSibling: l.nextSibling,
                previousSibling: l.previousSibling
            })), z++) : k.push({
                h: v,
                i: e
            })), v++), u && u !== x[v] && (f[e = D(u)] || (f[e] = !0, -1 === (e = E(x, u, v)) ? d.b && (a.push(t({
                type: "childList",
                target: c.j,
                removedNodes: [u],
                nextSibling: p[q + 1],
                previousSibling: p[q - 1]
            })), z--) : k.push({
                h: e,
                i: q
            })), q++));
            k && g(k, b,
                x, p, z)
        }
        var h;
        n(b, c);
        return h
    }

    function B(a, b) {
        var c = !0;
        return function g(a) {
            var h = {
                j: a
            };
            !b.c || 3 !== a.nodeType && 8 !== a.nodeType ? (b.a && c && 1 === a.nodeType && (h.a = F(a.attributes, function(a, c) {
                if (!b.d || b.d[c.name]) a[c.name] = c.value;
                return a
            })), c && (b.b || b.c || b.a && b.e) && (h.b = K(a.childNodes, g)), c = b.e) : h.c = a.nodeValue;
            return h
        }(a)
    }

    function D(a) {
        try {
            return a.id || (a.mo_id = a.mo_id || G++)
        } catch (b) {
            try {
                return a.nodeValue
            } catch (c) {
                return G++
            }
        }
    }

    function K(a, b) {
        for (var c = [], d = 0; d < a.length; d++) c[d] = b(a[d], d, a);
        return c
    }

    function F(a, b) {
        for (var c = {}, d = 0; d < a.length; d++) c = b(c, a[d], d, a);
        return c
    }

    function E(a, b, c, d) {
        for (; c < a.length; c++)
            if ((d ? a[c][d] : a[c]) === b) return c;
        return -1
    }
    w._period = 30;
    w.prototype = {
        observe: function(a, b) {
            for (var c = {
                    a: !!(b.attributes || b.attributeFilter || b.attributeOldValue),
                    b: !!b.childList,
                    e: !!b.subtree,
                    c: !(!b.characterData && !b.characterDataOldValue)
                }, d = this.g, g = 0; g < d.length; g++) d[g].m === a && d.splice(g, 1);
            b.attributeFilter && (c.d = F(b.attributeFilter, function(a, b) {
                a[b] = !0;
                return a
            }));
            d.push({
                m: a,
                l: I(a,
                    c)
            });
            this.f || H(this)
        },
        takeRecords: function() {
            for (var a = [], b = this.g, c = 0; c < b.length; c++) b[c].l(a);
            return a
        },
        disconnect: function() {
            this.g = [];
            clearTimeout(this.f);
            this.f = null
        }
    };
    var G = 1;
    return w
}(void 0);